<script type="text/javascript">
	var $kategoriadd_content = $("#kategoriadd_content");

	$(document).ready(function () {
		var theme = 'fresh';

		var kategoripost_id = $("#kategoripost_id");
		var kategoripost_task = $("#kategoripost_task");
		var kategoriadd_save = $("#kategoriadd_save");
		var kategoriadd_cancel = $("#kategoriadd_cancel");
		var kategoripost_nama = $("#kategoripost_nama");
		var kategoripost_keterangan = $("#kategoripost_keterangan");


		$('.field_input').addClass('jqx-input');
		$('.field_input').addClass('field');
		$('.field_input').addClass('jqx-rc-all');

		kategoriadd_save.jqxButton({ theme : theme, width : '70px', height : '18px' });
		kategoriadd_cancel.jqxButton({ width : '70px' , height : '18px' ,theme : theme });

		/* function */

		kategoriadd_cancel.click(function(){
			$('#mainpanelcontent').empty();
			$('<img src="./images/loader.gif" style="margin:50px auto auto 390px;">').appendTo('#contents');
			$('#mainpanelcontent').load('index.php/c_kategori/kategori_load');
		});
		kategoriadd_save.click(function(){
			var id = "";
			var nama = "";
			var deskripsi = "";
			var task = "";

			id = kategoripost_id.val();
			nama = kategoripost_nama.val();
			deskripsi = kategoripost_keterangan.val();
			task = kategoripost_task.val();

			if(task == ""){
				task = "create";
			}
			$.ajax({
				type : 'POST',
				url : 'index.php/c_kategori/kategori_save',
				data : {
					id : id,
					nama : nama,
					deskripsi : deskripsi,
					task : task
				},success : function(msg){
					var result = eval(msg);
					switch(result){
						case 1:
							$('#mainpanelcontent').empty();
							$('<img src="./images/loader.gif" style="margin:50px auto auto 390px;">').appendTo('#contents');
							$('#mainpanelcontent').load('index.php/c_kategori/kategori_load');
							alert("Data berhasil disimpan");
							break;
						default:
							alert("Data gagal disimpan");
							break;
					}
				}
			});
		});

		<?php
			if(isset($dataDetail)){
		?>
			kategoripost_id.val('<?php echo $dataDetail->id; ?>');
			kategoripost_nama.val('<?php echo $dataDetail->kategori; ?>');
			kategoripost_keterangan.val('<?php echo $dataDetail->desk; ?>');
			kategoripost_task.val('update');
		<?php
			}
		?>

	});

</script>
<!-- Begin content -->
<div class="modal_header">
		<span>Kategori Form</span>
	</div>
<div class="modal_content">
<div id="kategoriadd_content">
	<input type="hidden" id="kategoripost_id">
	<input type="hidden" id="kategoripost_task">
	<form action="" method="post">
		<p>
			<label>Kategori:</label><br/>
			<input type="text" id="kategoripost_nama" class="field_input" style="width:300px"/>
		</p>
		<br/>
		<p>
			<label>Keterangan:</label><br/>
			<textarea rows="7" cols="50" id="kategoripost_keterangan"></textarea>
		</p>
		<br/><br/>
		<p><table align="left">
			<tr align="left">
				<td>
					<div id='kategoriadd_save'>
					<img style='float: left; margin: 0px;' src='./images/icons/save.gif' />
					<div style='float: left; margin-left: 4px;'>Simpan</div>
				</div>
				</td>
				<td>
					<div id='kategoriadd_cancel'>
					<img style='float: left; margin: 0px;' src='./images/icons/cross.gif' />
					<div style='float: left; margin-left: 4px;'>Cancel</div>
				</div>
				</td>
			</tr>
		</table>
		</p>
		<p>&nbsp;</p>
	</form>
</div>
</div>
<!-- End left column window -->
